package com.adaxi.adc.business.manager.controller;

import com.adaxi.adc.business.manager.mapper.ManagerMapper;
import com.adaxi.adc.business.manager.pojo.Manager;
import com.adaxi.adc.business.manager.service.ManagerService;
import com.adaxi.adc.business.manager.vo.ManagerVo;
import com.adaxi.adc.common.common.CommonResult;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "[后台管理系统]管理员登录接口",value = "login")
@RestController
public class LonginController {

    @Autowired
    ManagerService managerService;
    /**
     * 正确案例
     * @return
     */

    @PostMapping ("/login")
    @ApiOperation(value = "管理员登录", notes = "管理员登录")
    public CommonResult login(@RequestBody ManagerVo managerVo){
        QueryWrapper<Manager> wrapper=new QueryWrapper<>();
        wrapper.eq("username",managerVo.getUsername()).eq("password",managerVo.getPassword());

        Manager manager=managerService.getOne(wrapper);
        if(manager!=null){
        return CommonResult.SUCCESS("登陆成功",manager);
        }
        return CommonResult.FAILURE("登录失败");
    }

}
